<template>
  <div class="myContainer">
    <el-row class="myTitleBorderBottom">
      <el-col :span="12" class="myLineHeight_40px">{{this.title}}</el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="24">
        <el-table
          ref="multipleTable"
          v-loading="loading"
          :data="tableData"
          :border = true
          :stripe = true
          style="width: 100%"
          @selection-change="handleSelectionChange">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            label="序号"
            type="index"
            width="100">
          </el-table-column>
          <el-table-column
            prop="COUPONNAME"
            label="类型名称"
            >
          </el-table-column>
          <el-table-column
            prop="COST"
            label="面值金额"
            >
          </el-table-column> 
          <el-table-column
            prop="REQFEE"
            label="要求金额"
            >
          </el-table-column> 
          <el-table-column
            prop="DURATION"
            label="时长(天)"
            >
          </el-table-column> 
          <el-table-column
            label="操作"
            width="100">
            <template scope="scope">
              <el-button type="text primary" @click="modify(scope.row.COUPON_ID)" class="look" size="small">编辑</el-button> 
            </template>
          </el-table-column>
        </el-table>

        <div class="block">                    
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page_num"
            :page-sizes="[10, 15]"
            :page-size="page_size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>
      </el-col>
    </el-row>   
  </div>
</template>

<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myColorRed{
    color: #f00;
  }
</style>

<script>
  import { getCashCouponList } from '@/api/online';
  import qs from "querystring";

  export default {
    data(){
      return{  
        title:"代金券类型",    
        tableData:[],  
        total:null, //总条数  
        page_num: 1, //当前页码
        page_size: 10, //每页显示多少条 
        loading:false
      }
    },
    created() {
      document.title=this.title;
      this.onGetCashCouponList();
    },
    filters: {
      
    },
    methods:{
       onGetCashCouponList() {//拉取热搜词列表
        let vm = this;
        const params = {
          rows:vm.page_size,
          page:vm.page_num
        }
        vm.loading=true;
        getCashCouponList(params)
        .then(response => {
          let res = response.data;
          vm.tableData = res.rows;
          vm.total = res.total;
          vm.loading=false;
        })
        .catch(error => {
          vm.loading=false;
          console.log("拉取列表失败",error);
        });
      },
      handleSizeChange(val) {
        this.page_size = val;
      },
      handleCurrentChange(val) {
        this.page_num = val;
      },
      handleSelectionChange(val) {
      },
      modify(c_id){//编辑
        this.$router.push({
          path:"/cashCouponComponents",
          query: {type: 'update', id:c_id}
        })
      }
    }

  }


</script>



